package com.woniuxy.exam.controller;

import com.woniuxy.exam.common.Result;
import com.woniuxy.exam.common.config.TencentCOSUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 腾讯云文件上传
 */
@Slf4j
@RestController
@RequestMapping(value = "/tencent/")
public class UploadController {
    //依赖注入
    @Autowired
    private TencentCOSUtil tencentCOSUtil;
 
    @PostMapping("/upload")
    public Result upload(MultipartFile image) {
        log.info("正在上传，文件名{}",image.getOriginalFilename());
        String url = tencentCOSUtil.upLoadFile(image);
        log.info("文件的Url：{}",url);
 
        return Result.ok(url);
 
    }
}